package cn.zhibang.yygh2.service.login.controller;

import cn.zhibang.yygh2.common.util.result.Result;
import cn.zhibang.yygh2.model.model.user.Admin;
import cn.zhibang.yygh2.model.model.user.Login;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

@Api(tags = "用户登录管理管理")
@RestController
@RequestMapping("/admin/user")
public class LoginController {



    @ApiOperation("管理员登录")
    @PostMapping("/login")
    public Result doLogin(@RequestBody Admin admin) {
        System.out.println(admin.getUsername() + "\t" + admin.getPassword());
        //1.访问数据库验证
        //2.生成token
        //3.响应token
        HashMap<String, Object> map = new HashMap<>();
        map.put("token", "admin123");
        return Result.ok(map);
    }

    //info
    @ApiOperation("获得管理员信息")
    @GetMapping("/info")
    public Result getInfo() {
        //TODO：数据库获取管理员信息
        HashMap<String, Object> map = new HashMap<>();
        map.put("roles", "[admin]");
        map.put("name", "admin");
        map.put("avatar", "https://img03.sogoucdn.com/app/a/100520093/d71a6360ba8601ff-19264876bfd6a308-dfbd047d3bb4f2621f01d7ae18979b6e.jpg");
        return Result.ok(map);
    }

    @ApiOperation("管理员登出")
    @PostMapping("/logout")
    public Result dologout() {
        //TODO：注销
        return Result.ok();
    }



}
